package ace.module.upms.core.impl.manager;

import ace.cmp.data.spring.data.jdbc.querydsl.rsql.core.manager.DtoManager;
import ace.module.upms.api.model.dto.UpmsRoleAccountDto;
import ace.module.upms.core.impl.dao.entity.UpmsRoleAccount;
import java.util.AbstractMap.SimpleEntry;
import java.util.List;
import org.springframework.transaction.annotation.Transactional;

/**
 * 角色与账户关联 spring data jdbc querydsl rsql manager.
 *
 * @author Caspar
 */
public interface UpmsRoleAccountManager extends DtoManager<UpmsRoleAccount, Long, UpmsRoleAccountDto> {

  List<UpmsRoleAccount> getByRoleIdAndIamAccountIdEntryAndDeleteFlagIsFalse(Long upmsAppId, List<SimpleEntry<Long, Long>> roleIdWithAccountIdEntryList);

  boolean noneMatch(List<UpmsRoleAccount> roleAccounts, Long upmsRoleId, Long iamAccountId);

  boolean anyMatch(List<UpmsRoleAccount> roleAccounts, List<SimpleEntry<Long, Long>> roleIdAndAccountIds);

  UpmsRoleAccount build(Long upmsAppId, Long upmsRoleId, Long iamAccountId);

  List<UpmsRoleAccount> getByUpmsAppIdAndIamAccountIdIn(Long upmsAppId, List<Long> iamAccountIds);

  void insertNewAndDeleteByIdIn(List<UpmsRoleAccount> newUpmsRoleAccounts, List<Long> deleteUpmsRoleAccountIds);
}